'''
Created on 2012-8-16

@author: johnny
'''
import time
import unittest
import cmd

class Test(unittest.TestCase):


    def setUp(self):
        pass


    def tearDown(self):
        pass


    def testName(self):
#        self.vm = vm.VMS("vm-test")
#        self.vm.set_cfg('numVcpusAllocated', '2')
        self.control = cmd.Manager()
        img = self.control.get_img_path("192.168.200.6", 'defaultlocal', 'winxp-IDE-002.img')
        vm = self.control.create("vm-testa", "192.168.200.6", img=img)
        vm.start(wth_vnc=True)
#        vm.is_started(120)
#        time.sleep(10)
#        vm.restart()
#        time.sleep(40)
#        vm.is_started(120)
#        vm.shutdown()
#        vm.is_down()
        time.sleep(20)
        
#        cloned = self.control.clone_vm(vm, "clone_auto", 'defaultlocal')
#        
#        self.control.check_clone(cloned)
#        
#        vm.start(wth_vnc=True)
#        cloned.start(wth_vnc=True)
#        vm.is_started()
#        cloned.is_started()
#        cloned.shutdown()
#        time.sleep(10)
#        cloned.is_down()
#                
#        self.control.delete_vm("192.168.200.6", vm, False)
#        self.control.delete_vm("192.168.200.6", cloned, True)
        #self.control.teardown()
        
#    def testAnother(self):
#        self.vm = vm.VMS("vm-test1")
#        self.vm.set_cfg('numVcpusAllocated', '2')
#        self.control = cmd.Commander()
#        img = self.control.get_img_path("192.168.200.6", 'defaultlocal', 'winxp-IDE-002.img')
#        self.control.create(self.vm, "192.168.200.6", img=img)
#        self.vm.start()
#        print self.vm.isStarted(120)
#        time.sleep(10)
##        self.vm.restart()
##        time.sleep(40)
#        self.vm.poweroff()
#        time.sleep(20)        
#        self.control.delete_vm("192.168.200.6", self.vm, False)
#        #self.control.teardown()
#        
#    def testB(self):
#        self.vm = vm.VMS("vm-test2")
#        self.vm.set_cfg('numVcpusAllocated', '2')
#        self.vm.set_cfg('memoryAllocatedInMb', '2048')
#        self.control = cmd.Commander()
#        img = self.control.get_img_path("192.168.200.6", 'defaultlocal', 'winxp-IDE-002.img')
#        self.control.create(self.vm, "192.168.200.6", img=img)
#        self.vm.start()
#        print self.vm.isStarted(120)
#        time.sleep(10)
##        self.vm.restart()
##        time.sleep(40)
#        self.vm.poweroff()
#        time.sleep(20)        
#        self.control.delete_vm("192.168.200.6", self.vm, False)
#        #self.control.teardown()


if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()